<?php

namespace App\Entities;

class ConvertibleCardEntity extends ABaseEntity
{
    public const SALE_ON = 1;
    public const SALE_DOWN = 0;

    public function __construct(ConvertibleCardModel $model)
    {
        $this->model = $model;
    }

    /**
     * 上架中
     * @return bool
     */
    public function onSale(): bool {
        return $this->getOnSale() === self::SALE_ON;
    }

    /**
     * @return int
     */
    public function getId()
    {
        return (int)$this->model->id;
    }

    #title
    public function getTitle()
    {
        return $this->model->title;
    }

    public function setTitle($title)
    {
        return $this->model->title = $title;
    }

    #type
    public function getType()
    {
        return $this->model->type;
    }

    public function setType($type)
    {
        return $this->model->type = $type;
    }

    #value
    public function getValue()
    {
        return $this->model->value;
    }

    public function setValue($value)
    {
        return $this->model->value = $value;
    }

    #price
    public function getPrice()
    {
        return $this->model->price;
    }

    public function setPrice($price)
    {
        return $this->model->price = $price;
    }

    #old price
    public function getOldPrice()
    {
        return $this->model->old_price;
    }

    public function setOldPrice($oldPrice)
    {
        return $this->model->old_price = $oldPrice;
    }

    #on sale
    public function getOnSale()
    {
        return $this->model->on_sale;
    }

    public function setOnSale($onSale)
    {
        return $this->model->on_sale = $onSale;
    }

    #start
    public function getStartSale()
    {
        return $this->model->start_sale;
    }

    public function setStartSale($startSale)
    {
        return $this->model->start_sale = $startSale;
    }

    #end
    public function getEndSale()
    {
        return $this->model->end_sale;
    }

    public function setEndSale($endSale)
    {
        return $this->model->end_sale = $endSale;
    }

    #duration

    /**
     * @return int
     */
    public function getDuration()
    {
        return $this->model->duration;
    }

    public function setDuration($duration)
    {
        return $this->model->duration = $duration;
    }

    #purchase
    public function getPurchaseLimit()
    {
        return $this->model->purchase_limit;
    }

    public function setPurchaseLimit($purchaseLimit)
    {
        return $this->model->purchase_limit = $purchaseLimit;
    }

    #banner img
    public function getBanner()
    {
        return $this->model->banner;
    }

    public function setBanner($banner)
    {
        return $this->model->banner = $banner;
    }

    #sold count

    /**
     * @return int
     */
    public function getSoldCount(): int
    {
        return $this->model->sold_count;
    }

    /**
     * @param int $soldCount
     * @return int
     */
    public function setSoldCount(int $soldCount)
    {
        return $this->model->sold_count = $soldCount;
    }

    /**
     * @param int $num
     */
    public function addSoldCount(int $num = 1)
    {
        $this->setSoldCount($this->getSoldCount() + $num);
    }

    #detail img
    public function getDetailImage()
    {
        return $this->model->detail_image;
    }

    public function setDetailImage($detailImage)
    {
        return $this->model->detail_image = $detailImage;
    }

    #operator
    public function getOperator()
    {
        return $this->model->operator;
    }

    public function setOperator($operator)
    {
        return $this->model->operator = $operator;
    }

    #created at
    public function getCreatedAt()
    {
        return $this->model->created_at;
    }

    public function setCreatedAt($createdAt)
    {
        return $this->model->created_at = $createdAt;
    }
}
